/* 全局样式 */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #8e44ad;
    --secondary-color: #9b59b6;
    --accent-color: #f39c12;
    --text-color: #2c3e50;
    --light-color: #ecf0f1;
    --box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    --box-glow: 0 0 15px rgba(142, 68, 173, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px;
}

/* 标题样式 */
header {
    text-align: center;
    margin-bottom: 50px;
}

h1 {
    font-size: 3.5rem;
    margin-bottom: 10px;
    color: var(--primary-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: 20px;
}

/* 游戏信息样式 */
.game-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
}

.chances {
    font-size: 1.3rem;
    color: var(--primary-color);
    font-weight: 600;
    background: rgba(142, 68, 173, 0.1);
    padding: 10px 20px;
    border-radius: 50px;
    box-shadow: var(--box-shadow);
}

#remainingChances {
    color: var(--accent-color);
    font-size: 1.5rem;
    font-weight: 700;
}

.reset-button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--box-shadow);
}

.reset-button:hover {
    background: var(--secondary-color);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(142, 68, 173, 0.4);
}

/* 禁用状态的盲盒样式 */
.box.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.box.disabled:hover {
    transform: none !important;
}

.box.disabled::before {
    display: none;
}

/* 盲盒容器 */
.mystery-boxes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin: 40px auto;
    max-width: 800px;
}

/* 盲盒样式 */
.box {
    position: relative;
    height: 200px;
    perspective: 1000px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.box:hover {
    transform: translateY(-10px);
}

.box-front, .box-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: var(--box-shadow);
}

.box-front {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 5rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.box-back {
    background: linear-gradient(135deg, var(--accent-color), #e67e22);
    transform: rotateY(180deg);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
}

.box.flipped .box-front {
    transform: rotateY(180deg);
}

.box.flipped .box-back {
    transform: rotateY(0);
}

/* 盲盒动画效果 */
.box::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 20px;
    background: linear-gradient(45deg, #ff0, #f0f, #f00, #00f, #0ff);
    background-size: 400%;
    z-index: -1;
    filter: blur(20px);
    opacity: 0;
    transition: opacity 0.3s;
}

.box:hover::before {
    opacity: 1;
    animation: glowing 10s linear infinite;
}

@keyframes glowing {
    0% { background-position: 0 0; }
    50% { background-position: 400% 0; }
    100% { background-position: 0 0; }
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 100;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: flex;
    animation: fadeIn 0.5s forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    padding: 30px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    text-align: center;
    transform: scale(0.7);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-header {
    margin-bottom: 20px;
}

.modal-header h2 {
    color: var(--primary-color);
    font-size: 2rem;
}

.modal-body {
    margin-bottom: 30px;
}

.modal-body p {
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.prize-name {
    margin: 20px 0;
    padding: 20px;
    border-radius: 15px;
    background: linear-gradient(to right, rgba(142, 68, 173, 0.1), rgba(243, 156, 18, 0.1));
}

.prize-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 15px;
}

.prize-desc {
    font-size: 1.2rem;
    color: var(--text-color);
    line-height: 1.5;
    opacity: 0.9;
    margin-bottom: 20px;
}

.prize-image-container {
    margin: 20px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.prize-image {
    max-width: 100%;
    max-height: 200px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    border: 3px solid white;
    object-fit: contain;
    background-color: rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease-in-out;
    opacity: 0;
}

.prize-image.loaded {
    opacity: 1;
}

.prize-image[style*="display: none"] {
    opacity: 0;
}

.prize-image[src=""] {
    display: none;
}

.prize-image.loading {
    opacity: 0;
}

.prize-image.loaded {
    opacity: 1;
}

@keyframes pulse {
    0% { background-color: rgba(255,255,255,0.8); }
    50% { background-color: rgba(255,255,255,0.4); }
    100% { background-color: rgba(255,255,255,0.8); }
}

.prize-image.loading-placeholder {
    animation: pulse 1.5s infinite;
    display: block !important;
}

@media (max-width: 768px) {
    .prize-image {
        max-height: 150px;
    }
}

@media (max-width: 480px) {
    .prize-image {
        max-height: 120px;
    }
}

.close-modal {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-modal:hover {
    background: var(--secondary-color);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(142, 68, 173, 0.4);
}

/* 响应式调整 */
@media (max-width: 900px) {
    .mystery-boxes {
        max-width: 600px;
        gap: 20px;
    }
    
    .box {
        height: 160px;
    }
    
    h1 {
        font-size: 2.8rem;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }
    
    .mystery-boxes {
        max-width: 500px;
        gap: 15px;
    }
    
    .box {
        height: 140px;
    }
    
    .box-front {
        font-size: 4rem;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 2rem;
    }
    
    .container {
        padding: 15px;
    }
    
    .mystery-boxes {
        gap: 10px;
    }
    
    .box {
        height: 100px;
    }
    
    .box-front {
        font-size: 3rem;
    }
    
    .modal-content {
        padding: 20px;
    }
    
    .prize-name {
        font-size: 1.8rem;
    }
}